//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package test.集合.斗地主4.game;

import java.awt.Point;
import java.util.ArrayList;
import test.集合.斗地主4.domain.Poker;

public class Common {
    public Common() {
    }

    public static void move(Poker poker, Point from, Point to) {
        if (to.x != from.x) {
            double k = (double)1.0F * (double)(to.y - from.y) / (double)(to.x - from.x);
            double b = (double)to.y - (double)to.x * k;
            int flag = 0;
            if (from.x < to.x) {
                flag = 20;
            } else {
                flag = -20;
            }

            for(int i = from.x; Math.abs(i - to.x) > 20; i += flag) {
                double y = k * (double)i + b;
                poker.setLocation(i, (int)y);

                try {
                    Thread.sleep(5L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }

        poker.setLocation(to);
    }

    public static void rePosition(GameJFrame m, ArrayList<Poker> list, int flag) {
        Point p = new Point();
        if (flag == 0) {
            p.x = 50;
            p.y = 225 - (list.size() + 1) * 15 / 2;
        }

        if (flag == 1) {
            p.x = 400 - (list.size() + 1) * 21 / 2;
            p.y = 450;
        }

        if (flag == 2) {
            p.x = 700;
            p.y = 225 - (list.size() + 1) * 15 / 2;
        }

        int len = list.size();

        for(int i = 0; i < len; ++i) {
            Poker poker = (Poker)list.get(i);
            move(poker, poker.getLocation(), p);
            GameJFrame.container.setComponentZOrder(poker, 0);
            if (flag == 1) {
                p.x += 21;
            } else {
                p.y += 15;
            }
        }

    }
}
